﻿using UnityEngine;
using System.Collections;

public class FX_localrotate : MonoBehaviour {

	public bool bLocalRot = false;
	
	public Vector3 vRotationValue = new Vector3 (0, 0, 0);
	
	public float fTimeScale = 1.0f;
	
	Quaternion vOriginalRotation;
	
	float timer = 0;
	
	[SerializeField]
	AnimationCurve curveX;
	[SerializeField]
	AnimationCurve curveY;
	[SerializeField]
	AnimationCurve curveZ;
	
	void Start(){
		vOriginalRotation = transform.rotation;
	}
	void Update ()
	{
		
		Vector3 rotation;
		rotation.x = curveX.Evaluate(timer*fTimeScale)* vRotationValue.x;
		rotation.y = curveY.Evaluate(timer*fTimeScale)* vRotationValue.y;
		rotation.z = curveZ.Evaluate(timer*fTimeScale)* vRotationValue.z;

		if (bLocalRot) {
			transform.localRotation = Quaternion.Euler (rotation);
		} else {
			transform.localRotation = Quaternion.Euler (rotation)* vOriginalRotation;
		}

		timer += Time.deltaTime;
	}
}
